package com.lions.client.view.basepanel;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.lions.client.view.modulepanel.SpeechIntegerBox;
import com.lions.client.view.popup.MyPopupPanel;

public class CenterPopup extends MyPopupPanel{

	/**
	 * @param min
	 */
	public CenterPopup(MinBaseBuilder min){
		panel = new FlexTable();
		constructor = min;
		xb = new SpeechIntegerBox();
		yb = new SpeechIntegerBox();
		panel.setStyleName("popup");
		
		// Adds Module X Coordinate Label and Text Box
		panel.setWidget(0, 0, new Label("New Center X"));
		panel.setWidget(0, 1, xb);
		xb.setText(Integer.toString(constructor.getCenterX()));
		xb.setStyleName("integerboxstyle");
		xb.addStyleName("integerboxhint");
		
		// Adds Module Y Coordinate Label and Text Box
		panel.setWidget(1, 0, new Label("New Center Y"));
		panel.setWidget(1, 1, yb);
		yb.setText(Integer.toString(constructor.getCenterY()));
		yb.setStyleName("integerboxstyle");
		yb.addStyleName("integerboxhint");
		
		submit = new Button("Submit", new ClickHandler(){
			public void onClick(ClickEvent event) {
				constructor.setCenterX(xb.getValue());
				constructor.setCenterY(yb.getValue());
				
				constructor.build();
				constructor.display();
				hide();
			}
		});
		submit.setStyleName("buttonstyle");
		// Adds Panel to the Pop-Up
		panel.setWidget(4, 0, submit);
		center();
		setWidget(panel);
	}
	
	/** The panel. */
	private FlexTable panel;
	/** The submit. */
	private Button submit;
	/** The xb. */
	private final SpeechIntegerBox xb;
	
	/** The yb. */
	private final SpeechIntegerBox yb;
	
	/**
	 * The MinBaseBuilder
	 */
	private final MinBaseBuilder constructor;
}
